package com.example.simple_android_examples.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.example.simple_android.annotation.Receiver;
import com.example.simple_android_examples.constant.Constant;

// 默认程序启动时，使用Application注册为全局广播
@Receiver(actions = Constant.StandardReceiverConstant.ACTION)
//@Receiver(actions = Constant.StandardReceiverConstant.ACTION, whenToStart = com.example.simple_android.constant.Constant.ReceiverConstant.WAIT) // 不会再程序启动时，启动，当需要启动时，可以由开发者，决定启动的事件
public class StandardReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (Constant.StandardReceiverConstant.ACTION.equals(intent.getAction())) {
            Bundle extras = intent.getExtras();
            String string = extras.getString(Constant.StandardReceiverConstant.FLAG);
            System.err.println("标准广播接收者，接收到消息：".concat(string));
        }
    }
}
